How to create/Implement Meow Bottom Navigation Bar With Visibility in Android Studio With Java | Custom Bottom Navigation - RSM Developer

Meow Bottom Navigation With Visibility in Android Studio

Step 1Creating a new project

  • Open a new project.
  • We will be working on Empty Activity with language as Java. Leave all other options unchanged.
  • You can change the name of the project at your convenience.
  • There will be two default files named activity_main.xml and MainActivity.java.
Step 2: Navigate to Build scripts > build.gradle(module) file and add the following dependency to it and Syne Now

//meow-bottom-navigation=========================================================
implementation 'com.etebarian:meow-bottom-navigation:1.2.0'
And
targetSdk 33
compileSdk 33

Step 3: Navigate to Build scripts > settings.gradle(Project Setting) file and add the following dependency to dependencyResolutionManagement and Syne Now
jcenter()

Step 4: Open res -> layout ->activity_main.xml (or) main.xml and add following code:

In this step we open an XML file and add the code :-

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">


<!-- your app home activity ui start -->
<LinearLayout
android:visibility="gone"
android:id="@+id/Home"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#8BC34A"
>
<!-- design start your app ui-->
<TextView
android:id="@+id/button"
android:text="Home"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
/>
<!-- design end your app ui-->
</LinearLayout>
<!-- your app home activity ui end -->

<!-- your app search activity ui start -->
<LinearLayout
android:visibility="gone"
android:id="@+id/Search"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFEB3B"
>
<!-- design start your app ui-->
<TextView
android:text="Search"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
/>
<!-- design end your app ui-->
</LinearLayout>
<!-- your app search activity ui end -->

<!-- your app bookmark activity ui start -->
<LinearLayout
android:visibility="gone"
android:id="@+id/Bookmark"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF9800"
>
<!-- design start your app ui-->
<TextView
android:text="Bookmark"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
/>
<!-- design end your app ui-->
</LinearLayout>
<!-- your app bookmark activity ui start -->

<!-- your app Profile activity ui start -->

<LinearLayout
android:visibility="gone"
android:id="@+id/Profile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF5722"
>
<!-- design start your app ui-->
<TextView
android:text="Profile"
android:textStyle="bold"
android:textColor="@color/black"
android:textSize="20sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
/>
<!-- design end your app ui-->
</LinearLayout>
<!-- your app Profile activity ui end -->



<!-- MeowBottomNavigation start-->

<com.etebarian.meowbottomnavigation.MeowBottomNavigation
android:id="@+id/bnv_Main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:mbn_backgroundBottomColor="@color/teal_700"
app:mbn_circleColor="#ffffff"
android:layout_gravity="bottom"
app:mbn_countBackgroundColor="#ff6f00"
app:mbn_countTextColor="#ffffff"
app:mbn_defaultIconColor="#90a4ae"
app:mbn_rippleColor="#2f424242"
app:mbn_selectedIconColor="#3c415e"
app:mbn_shadowColor="#1f212121"
android:layout_alignParentBottom="true"/>
<!-- MeowBottomNavigation end-->


</RelativeLayout>

Step 5: Open Java -> package – > MainActivity.Java and add following code:

In this step we open an Java file and add the code :-

package com.rsmdeveloper.meowvisibility;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentTransaction;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import com.etebarian.meowbottomnavigation.MeowBottomNavigation;

import kotlin.Unit;
import kotlin.jvm.functions.Function1;

/**
* Created by RSM Developer on 31-01-2023.
* Follow Facebook : https://www.facebook.com/RSMDeveloper
* Subscribe Youtube : https://www.youtube.com/@RSMDeveloper
* Visit Website : https://rsmdeveloper.blogspot.com/
* Develope Your Creativity With RSM Developer
**/
public class MainActivity extends AppCompatActivity {
//=======================================
private MeowBottomNavigation bnv_Main;
//=======================================

//===============================================================
LinearLayout Home, Search, Bookmark, Profile;
//===============================================================
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//=======================================
bnv_Main = findViewById(R.id.bnv_Main);
bnv_Main.add(new MeowBottomNavigation.Model(1,R.drawable.home));
bnv_Main.add(new MeowBottomNavigation.Model(2,R.drawable.search));
bnv_Main.add(new MeowBottomNavigation.Model(3,R.drawable.bookmarks));
bnv_Main.add(new MeowBottomNavigation.Model(4,R.drawable.person));
//===============================================================
Home = findViewById(R.id.Home);
Search = findViewById(R.id.Search);
Bookmark = findViewById(R.id.Bookmark);
Profile = findViewById(R.id.Profile);
//===============================================================

//=======================================
bnv_Main.show(2,true);
Search.setVisibility(View.VISIBLE);
//=======================================
bnv_Main.setOnClickMenuListener(new Function1<MeowBottomNavigation.Model, Unit>() {
@Override
public Unit invoke(MeowBottomNavigation.Model model) {
switch (model.getId()){
case 1:
Home.setVisibility(View.VISIBLE);
Search.setVisibility(View.GONE);
Bookmark.setVisibility(View.GONE);
Profile.setVisibility(View.GONE);

break;
//===============================================================
case 2:
Home.setVisibility(View.GONE);
Search.setVisibility(View.VISIBLE);
Bookmark.setVisibility(View.GONE);
Profile.setVisibility(View.GONE);

break;
//===============================================================
case 3:
Home.setVisibility(View.GONE);
Search.setVisibility(View.GONE);
Bookmark.setVisibility(View.VISIBLE);
Profile.setVisibility(View.GONE);
break;
//===============================================================
case 4:
Home.setVisibility(View.GONE);
Search.setVisibility(View.GONE);
Bookmark.setVisibility(View.GONE);
Profile.setVisibility(View.VISIBLE);

break;
//===============================================================
}
return null;
}
});

}//=======================================
}

Step 6: Copy and paste your Icon (drawable)

Output:

Now run the App and you will see main topics and sub-topics listed.....


Meow Bottom Navigation Bar, Meow Bottom Navigation With Visibility, Implement Meow Bottom Navigation With Visibility in Android Studio,RSM Developer,

Post a Comment

Previous Post Next Post

যোগাযোগ ফর্ম